<template>
  <div class="tab-bar-item" @click="itemClick">
    <slot name="tabbarItemImg" v-if="!isActive"></slot>
    <slot name="tabbarItemImgActive" v-else></slot>
    <div :style="activeStyle"><slot name="tabbarItemText"></slot></div>
  </div>
</template>

<script>
// 单独的tabbarItem个体，设置了四个插槽
export default {
  components: {},
  props: {
    path:String
  },
  data() {
    return {
    activeColor:'#f39c12'
    };
  },
  watch: {},
  computed: {
    isActive(){
      return this.$route.path.indexOf(this.path) !== -1;
    },
    activeStyle(){
      return this.isActive ? {color:this.activeColor} : {}
    },
  },
  methods: {
    itemClick(){
      this.$router.push(this.path)
    }
  },
  created() {},
  mounted() {},
};
</script>
<style scoped>
.tab-bar-item{
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  font-size: 12px;
  font-weight: bold;
}
.tab-bar-item img{
  width:28px;
  height: 28px;
  vertical-align: bottom;
  margin-bottom: 3px;
}

</style>